var app = getApp(), Toast = require("../../libs/zanui/toast/toast");

Page({
    data: {},
    onLoad: function(t) {
        var a = t.id;
        this.setData({
            item_id: a
        }), this.getAuditDetail(a);
    },
    getAuditDetail: function(t) {
        var e = this;
        app.util.request({
            url: "entry/wxapp/item",
            cachetime: "0",
            data: {
                act: "detail",
                id: t,
                m: "superman_hand2"
            },
            success: function(t) {
                if (t.data.errno) e.showIconToast(t.errmsg); else {
                    var a = t.data.data;
                    e.setData({
                        detail: a.item
                    });
                }
            }
        });
    },
    auditChange: function(t) {
        t.detail.value ? this.setData({
            auditFail: !1
        }) : this.setData({
            auditFail: !0
        });
    },
    formSubmit: function(t) {
        var a = this, e = a.data.item_id, i = t.detail.value.audit ? 1 : 0, s = "";
        t.detail.value.reason && (s = t.detail.value.reason);
        var o = t.detail.formId, n = t.detail.value.title, u = t.detail.value.description;
        app.util.request({
            url: "entry/wxapp/item",
            cachetime: "0",
            data: {
                act: "audit",
                id: e,
                title: n,
                description: u,
                status: i,
                reason: s,
                form_id: o,
                m: "superman_hand2"
            },
            success: function(t) {
                t.data.errno ? a.showIconToast(t.errmsg) : (a.showIconToast("提交成功", "success"), 
                setTimeout(function() {
                    wx.navigateTo({
                        url: "../home/index"
                    });
                }, 1500));
            }
        });
    },
    showIconToast: function(t) {
        var a = 1 < arguments.length && void 0 !== arguments[1] ? arguments[1] : "fail";
        Toast({
            type: a,
            message: t,
            selector: "#zan-toast"
        });
    }
});